/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.tordroid.model;

import java.util.List;
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;

/**
 *
 * @author Christian Simon
 */
@Root
public class Character {

    @Element
    private String surname;
    @Element(required = false)
    private String lastname;
    @Attribute(required = false)
    private boolean availablility;
    @Element(required = false)
    private String background;
    @ElementList(required = false)
    private List<Story> stories;
    @Element(required = false)
    private Planet origin;
    @Attribute(required = false)
    private int age;
    @Attribute
    private String race;
    @Element(required = false)
    private CharacterClass characterClass;
    @Element
    private String faction;

    /**
     * @return the faction
     */
    public Faction getFaction() {
        return Faction.valueOf(faction);
    }

    /**
     * @param faction the faction to set
     */
    public void setFaction(Faction faction) {
        this.faction = faction.toString();
    }

    /**
     * @return the background
     */
    public String getBackground() {
        return background;
    }

    /**
     * @param background the background to set
     */
    public void setBackground(String background) {
        this.background = background;
    }

    public void removeStory(Story story) {
        stories.remove(story);
    }

   
    public Character(String titel, boolean availablility) {
        this();
        this.surname = titel;
        this.availablility = availablility;
    }

    public Character() {
        this.surname = "New Character";
        this.lastname = "";
        this.race = Race.None.toString();
        this.background = "None";
//        if (this.stories == null) {
//            this.stories = new ArrayList<Story>();
//            this.stories.add(new Story("Debugger","created while initializing Character()"));
//        }
        this.availablility = false;
        this.characterClass = new CharacterClass();
        this.faction = Faction.None.toString();
    }

    /**
     * @return the titel
     */
    public String getSurname() {
        return surname;
    }

    /**
     * @param titel the titel to set
     */
    public void setSurname(String titel) {
        this.surname = titel;
    }

    /**
     * @return the active
     */
    public boolean isAvailable() {
        return availablility;
    }

    /**
     * @param active the active to set
     */
    public void setAvailablility(boolean availablility) {
        this.availablility = availablility;
    }

    /**
     * @return the stories
     */
    public List<Story> getStories() {
        return stories;
    }

    /**
     * @param stories the stories to set
     */
    public void setStories(List<Story> stories) {
        this.stories = stories;
    }

    public void addStory(Story story) {
        this.stories.add(story);
    }

    /**
     * @return the origin
     */
    public Planet getOrigin() {
        return origin;
    }

    /**
     * @param origin the origin to set
     */
    public void setOrigin(Planet origin) {
        this.origin = origin;
    }

    /**
     * @return the age
     */
    public int getAge() {
        return age;
    }

    /**
     * @param age the age to set
     */
    public void setAge(int age) {
        this.age = age;
    }

    /**
     * @return the race
     */
    public String getRace() {
        return race;
    }

    /**
     * @param race the race to set
     */
    public void setRace(String race) {
        this.race = race;
    }

    /**
     * @return the legacy
     */
    public String getLastname() {
        return lastname;
    }

    /**
     * @param legacy the legacy to set
     */
    public void setLastname(String legacy) {
        this.lastname = legacy;
    }

    /**
     * @return the characterClass
     */
    public CharacterClass getCharacterClass() {
        return characterClass;
    }

    /**
     * @param characterClass the characterClass to set
     */
    public void setCharacterClass(CharacterClass characterClass) {
        this.characterClass = characterClass;
    }
}
